package content

import (
	"context"

	"server-go/api/reward/internal/svc"
	"server-go/api/reward/internal/types"
	"server-go/rpc/reward/types/reward"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateBaseInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateBaseInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBaseInfoLogic {
	return &UpdateBaseInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateBaseInfoLogic) UpdateBaseInfo(req *types.UpdateBaseInfoInput) (resp *types.UpdateBaseInfoOutput, err error) {
	resp = new(types.UpdateBaseInfoOutput)
	res, err := l.svcCtx.RewardRpc.UpdateBaseInfo(l.ctx, &reward.UpdateBaseInfoInput{
		Email:    req.Email,
		UserName: req.UserName,
	})
	if err != nil {
		return resp, err
	}
	resp = &types.UpdateBaseInfoOutput{
		NickName:  res.NickName,
		Email:     res.Email,
		Gender:    res.Gender,
		UserIntro: res.UserIntro,
		UserName:  res.UserName,
		Money:     res.Money,
	}
	return resp, nil
}
